package peng.yang.express.Adapter;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;
import peng.yang.express.Bean.PhoneRequest;
import peng.yang.express.R;

/**
 * Created by Administrator on 2016/7/1.
 */
public class CheckBaseAdapter extends BaseAdapter {
//shentong 888619334402
//shentong 229963929246
    private List<PhoneRequest> list;
    private Context context;
    private LayoutInflater inflater;

    public CheckBaseAdapter(Context context, List<PhoneRequest> list) {
        this.list = list;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHandler handler = new ViewHandler();
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.check_list_item, null);
            handler.state = (TextView) convertView.findViewById(R.id.tv_state);
            handler.time= (TextView) convertView.findViewById(R.id.tv_time);

            convertView.setTag(handler);
        } else {
            handler = (ViewHandler) convertView.getTag();
        }
        if(position==0){
            ImageView image02 = (ImageView) convertView.findViewById(R.id.image02);
            image02.setImageResource(R.drawable.position);
            handler.state.setTextColor(Color.RED);
            handler.time.setTextColor(Color.RED);
        }else {
            ImageView image02 = (ImageView) convertView.findViewById(R.id.image02);
            image02.setImageResource(R.drawable.recycle);
            handler.state.setTextColor(Color.GRAY);
            handler.time.setTextColor(Color.GRAY);
        }
        String state = list.get(position).getState().toString();
        String time = list.get(position).getTime().toString();
        handler.state.setText(state);
        handler.time.setText(time);

        return convertView;
    }
    static class ViewHandler {
        private TextView state;
        private TextView time;

    }
}
